#!/usr/bin/sh

if [ $# -ne 2 ]; then
	echo "Usage: sh launch.sh <erlang node name> [mac|vm]"
	exit 1
fi

NODE="$1"
SCRIPT="prj2server.erl"
NODES=10
FILES="\"files\""
REP=3
NUM_NEIGHBORS=3
S1='1'
MAC="mac"
VM="vm"

if [[ $2=$MAC ]]
then
    MACHINES="\"inst1@Adams-MacBook-Air.local,inst2@Adams-MacBook-Air.local\""
elif [[ $2=$VM ]]
then
    MACHINES="\"inst1@192.168.0.101,inst2@192.168.0.102\""
else
    echo "Unknown mode.  Accepts mac or vm."
    exit 1
fi

echo $MACHINES
echo "c(prj2server). c(db). c(fileupdate). c(fileretrieve). c(prj2). prj2:init($NODES, $FILES, $REP, $MACHINES,$NUM_NEIGHBORS). q()." | erl -name ${NODE}
